package 线程状态;

/**
 * @Author: 李佳芬
 * @Description: 线程的五个状态
 * @DateTime: 2023/3/31 17:15
 **/
public class TestState {
    public static void main(String[] args) throws InterruptedException {

      Thread thread = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
          System.out.println("。。。。。。。。。。。。。。。。。。。。。");
        });
        Thread.State state = thread.getState();   // NEW 状态
        System.out.println(state);

        thread.start(); // 启动线程
         state = thread.getState(); // 更新线程状态
        System.out.println(state);
        while (state != Thread.State.TERMINATED){
            Thread.sleep(100);
            state = thread.getState();
            System.out.println(state);
        }

    }

}
